package com.mtl.web.controller;


import com.mtl.article.domain.Article;
import com.mtl.article.service.IArticleService;
import com.mtl.common.tool.model.Page;
import com.mtl.front.domain.Sort;
import com.mtl.member.domain.Member;
import com.mtl.member.service.IMemberService;

import com.mtl.sort.service.ISortService;
import com.mtl.user.controller.UserController;
import com.mtl.user.domain.User;
import com.mtl.user.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Controller
@RequestMapping("article")
public class IndexController {
    @Autowired
    private IMemberService memberService;
    @Autowired
    IUserService userService;
    @Autowired
    IArticleService articleService;
    @Autowired
    private ISortService sortService;
    @RequestMapping(value = "/index")
    public String index (Model model){
        model.addAttribute("carsouel",articleService.findBySid(1,5,30));
        model.addAttribute("data1",articleService.findOrder(1,5,null,null,null,null));
        model.addAttribute("today",articleService.findOrder(1,1,null,null,null,null));
       model.addAttribute("NEWS",articleService.findOrder(1,3,null,null,true,42));
       model.addAttribute("artCount",articleService.findCount());
        model.addAttribute("sortCount",sortService.findCount());
        System.out.println(articleService.findCount());
        System.out.println(sortService.findCount());
        return "index";
    }
    //分类
    /*@RequestMapping(value = "/articleSort")
    public String test1 (Model model){

        Page<Member> detail=memberService.findPage(2,5);
        System.out.println(detail);
        model.addAttribute("detail",detail);
        return "articleSort";
    }*/
    /*@RequestMapping("/articlePage")
    public String test3 (Model model){
        *//*Page<Member> detail=memberService.findPage(2,5);
        System.out.println(detail);
        model.addAttribute("detail",detail);*//*
        return "articlePage";
    }*/
    @RequestMapping("/search")
    public String search (Model model,@ModelAttribute Article article,String search,Integer page,Integer size){
        model.addAttribute("search",articleService.findPage(1,9999,search));
//        model.addAttribute("articleList", null);
//        model.addAttribute("pages",null);
//        model.addAttribute("frontPage",null);
//
//        model.addAttribute("sortName", null);
//        model.addAttribute("sortId",null);

        return "search";
    }
   /* @RequestMapping("/about")
    public String test4 (Model model){
        *//*Page<Member> detail=memberService.findPage(2,5);
        System.out.println(detail);
        model.addAttribute("detail",detail);*//*
        return "about";
    }*/
    /*@RequestMapping("/detail")
    public String test5 (Model model){
        *//*Page<Member> detail=memberService.findPage(2,5);
        System.out.println(detail);
        model.addAttribute("detail",detail);*//*
        return "detail";
    }
*/



}
